package mms

import grails.test.*




class MobileServiceTests extends GrailsUnitTestCase {

    def mobileService
    def Long id;
    def Long cid


    protected void setUp() {
        mobileService = new MobileService()
        //mockFor(MobileService,[mobileService] )

        mockDomain(mms.InspectionLog)
        mockDomain(mms.InspectionItem)

        id = mobileService.createInspectionLog();

        def company = new MedicineCompany(name:"name"
                    ,loginName:"loginName"
                    ,password:"password"
                    ,address:"address"
                    ,contact:"contact"
                    ,level:"level"
                    ,sellOfYear:"sellOfYear"
                    ,gis:"gis"
                    ,latitude:"latitude"
                    ,longitude:"longitude"
                    ,licence:"licence"
                    ,licenceIssue:"licenceIssue"
                    ,medicalProducts:"medicalProducts"
                    ,medicalProductsIssue:"medicalProductsIssue"
                    ,area:"area"
                    ,nature:"nature"
                    ,scopeOfBusiness:"scopeOfBusiness"
                    ,GSPLicence:"GSPLicence")

        mockDomain(MedicineCompany, [company])

        company.save(flush:true)

        cid = company.id
 
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testCreateInspectionLog() {
        def tempid = mobileService.createInspectionLog();
        assert InspectionLog.list().size() == 2
    }

    void testInspectionLog() {
    
        def r1 = mobileService.saveInspectionLog(id , cid, "InspectionType" , "executor") 
        assert r1
        

        def r2 = mobileService.saveInspectionItem( id , 
            [new InspectionItem(content = 'content',result = 'result', category = 'category').save(flush:true)]) 
        assert r2

    }
}
 